// util.h - WGAL Utility header
#ifndef WGAL_UTIL_H
#define WGAL_UTIL_H

#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000

#include <wgal/common.h>

#ifdef __cplusplus
extern "C"
{
#endif // __cplusplus

// utility functions



#ifdef __cplusplus
}
#endif // __cplusplus

// utility macros
#define COLOR_ARGB(a,r,g,b)		((WGALColor)((((a)&0xff)<<24)|(((r)&0xff)<<16)|(((g)&0xff)<<8)|((b)&0xff)))
#define COLOR_XRGB(r,g,b)		COLOR_ARGB(255,r,g,b)
#define COLOR_RGBA(r,g,b,a)		COLOR_ARGB(a,r,g,b)
#define COLOR_ALPHA(a,c)		((WGALColor)((((a)&0xff)<<24)|((c)&0x00FFFFFF)))

#define COLOR_RED				COLOR_XRGB(255,0,0)
#define COLOR_GREEN				COLOR_XRGB(0,255,0)
#define COLOR_BLUE				COLOR_XRGB(0,0,255)
#define COLOR_BLACK				COLOR_XRGB(0,0,0)
#define COLOR_WHITE				COLOR_XRGB(255,255,255)

#define IS_STRING_EMPTY(x)		((x)[0]=='\0')
#define IS_STRING_NULL_OR_EMPTY	(((x)!=NULL)?IS_STRING_EMPTY(x):TRUE)
#define TO_BOOLEAN(x)			((x)?TRUE:FALSE)
#define MAX(x,y)				((x>y)?(x):(y))
#define MIN(x,y)				((x<y)?(x):(y))

#define FPS_TO_INTERVAL(x)		(1000.0f/(x))

#endif // !WGAL_UTIL_H